<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="java.io.*,java.util.*,java.sql.*"%>
<%@ page import="javax.servlet.http.*,javax.servlet.*"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<%
	//session = request.getSession(false);
	if (session == null || session.getAttribute("loggedIn") == null) {//logoogle
		//not logged
%><a href="FormLogin.jsp">Inicie Sesion</a>
<%
	} else if ((Integer) session.getAttribute("priv") == 1) {
%><a href="FormLogin.jsp">No tiene los privilegios necesarios</a>
<%
	} else {
		//logged
%>
<head>
<link rel="stylesheet" href="css/metro-bootstrap.css">
<link rel="stylesheet" href="css/modalcss.css">
<link href="css/iconFont.css" rel="stylesheet">
<script src="js/jquery-1.11.1.js"></script>
<script src="js/modal2.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Panel de Control</title>

<jsp:include page="Nav.html"></jsp:include>
<%String nameCat = request.getParameter("name");%>




</head>
<body class="metro">
<h1 style="text-align:center" ><button onclick="location.href='AdminCat.jsp'"><</button><n id="header" ><%=nameCat %></n></h1><div id='centered'><button class="button success"  data-add="">A&ntilde;adir Item</button></div>
	<sql:setDataSource var="snapshot" driver="com.mysql.jdbc.Driver"
		url="jdbc:mysql://localhost/cot" user="root" password="Beyer9499" />

<sql:query dataSource="${snapshot}" var="result">
Select iid, info, activo from item where cid =(select cid from categoria where info='<%=nameCat %>') order by iid desc;

</sql:query>
	<table class="table hovered bordered" id="table">
		<thead>
			<tr>
				<th class="text-left">Item</th>
				<th class="text-left">Eliminar</th>
				<th class="text-left" >Modificar</th>
			</tr>
		</thead>	
		<tbody>
			<c:forEach var="row" items="${result.rows}">
				<tr class="${row.activo}">
					<td><c:out value="${row.info}" /></td>
					<td id = "tdDrop"><button id="buttDrop" class="button warning" data-drop="">Dar de Baja</button></td>
					<td id = "tdChange"><button class="button default" data-change="">Cambiar Nombre</button></td>
				</tr>
			</c:forEach>
			</tbody>
	</table>
</body>
</html>
<%
	}
%>